<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/pages/common/meta.jsp" %>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/uce-static/iconfont/iconfont.css"/>
<style>
    .panel-title div{ float: left;}
    .panel-title a{float: left;margin: 0 5px 0 !important;}
</style>
<script>
    var woKind = $("#woKind").val();
    var woCode = $("#woCode").val();
    debugger;
    /**
     * 未处理内容
     * 罚款金额无范围展示
     * */
    function getInternalDutyData() {
        var end =endEditing();
        var fixDutyData;
        if(end){
            fixDutyData = $("#dg").datagrid('getData').rows;
        }
        return fixDutyData;
    }
    /**
     * 责任人选中事件
     * */
    function personLiableCOnSelect(data){
        var row = $('#dg').datagrid('getSelected');
        row.personLiableCode=data.empCode;
        row.personLiableName=data.empName;
    }
    /**
     * 责任机构选中事件
     * */
    function dutyOrgCOnSelect(data){
        var row = $('#dg').datagrid('getSelected');
        row.dutyOrgCode=data.baseOrgCode;
        row.dutyOrgName=data.orgFullName;
    }

    function disableDutyAndPersonLiable(row,rowIndex,data) {
        row.dutyOrgCode="";
        row.dutyOrgName="";
        var dutyOrgCtarget = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'dutyOrgC'}).target;
        dutyOrgCtarget.combobox('clear');
        var ed = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'dutyOrgC'});
        $(ed.target).combobox('disable');//不可编辑
        $(ed.target).combobox('clear');//清空值 2018-07-17


        var penaltiesTarget = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'penalties'}).target;
        penaltiesTarget.numberbox('clear');
        var ed1 = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'penalties'});
        $(ed1.target).numberbox('disable');//不可编辑
        $(ed1.target).numberbox('clear');
        $(ed1.target).numberbox('setValue', 0);

        row.personLiableCode="";
        row.personLiableName="";
        var personLiableCtarget = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'personLiableC'}).target;
        personLiableCtarget.combobox('clear');

        var ed2 = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'personLiableC'});
        $(ed2.target).combobox('disable');//不可编辑
        $(ed2.target).combobox('clear');//清空值 2018-07-17
        if( row.dutyOrgCode){
            var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
            $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'dutyOrgC'}).target.combobox('setValue',row.dutyOrgName);
            $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'dutyOrgC'}).target.combobox('setText',row.dutyOrgName);
            //切换责任方清空责任机构
            if(oldDuty != data.typeCode){
                target.combobox('clear');//清除原来的数据
            }
        }

    }

    /**
     * 责任方选中事件
     * */
    function dutyOnSelect(data){
        var row = $('#dg').datagrid('getSelected');
        //row.dutyOrgCode="";
        //row.dutyOrgName="";
        //row.personLiableCode="";
        //row.personLiableName="";
        debugger;
        row.duty=data.typeCode;
        row.dutyName=data.typeName;
        var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
        if(data.typeName == '客服责任' ){
            row.dutyOrgCode="";
            row.dutyOrgName="";
            var dutyOrgCtarget = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'dutyOrgC'}).target;
            dutyOrgCtarget.combobox('clear');
            var ed = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'dutyOrgC'});
            $(ed.target).combobox('disable');//不可编辑
            $(ed.target).combobox('clear');//清空值 2018-07-17
            var ed1 = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'personLiableC'});
            $(ed1.target).combobox('enable');//可编辑
            var target = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'personLiableC'}).target;
            target.combobox('clear'); //清除原来的数据

            var penaltiesTarget = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'penalties'}).target;
            penaltiesTarget.numberbox('clear');
            var ed2 = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'penalties'});
            $(ed2.target).numberbox('enable');//可编辑
            $(ed2.target).numberbox('clear');
            var url = G_CTX_PATH+'/cs/CsWoDuty/getAllCccs.do';
            target.combobox('reload', url);
        } else  if (data.typeName == '客户原因' ||data.typeName == '总部') {
            disableDutyAndPersonLiable(row,rowIndex,data);

        }else{
            row.personLiableCode="";
            row.personLiableName="";
            var personLiableCtarget = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'personLiableC'}).target;
            personLiableCtarget.combobox('clear');

            var ed = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'personLiableC'});
            $(ed.target).combobox('disable');//不可编辑
            $(ed.target).combobox('clear');//清空值 2018-07-17
            var ed1 = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'dutyOrgC'});
            $(ed1.target).combobox('enable');//可编辑
            var penaltiesTarget = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'penalties'}).target;
            penaltiesTarget.numberbox('clear');
            var ed2 = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'penalties'});
            $(ed2.target).numberbox('enable');//可编辑
            $(ed2.target).numberbox('clear');
            var target = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'dutyOrgC'}).target;
            var url = G_CTX_PATH + '/cs/omg/org/findOrgCmsByOrgTypeAllStatusDB.do';
            target.combobox('reload', url);
            if( row.dutyOrgCode){
                var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
                $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'dutyOrgC'}).target.combobox('setValue',row.dutyOrgName);
                $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'dutyOrgC'}).target.combobox('setText',row.dutyOrgName);
                //切换责任方清空责任机构
                if(oldDuty != data.typeCode){
                    target.combobox('clear');//清除原来的数据
                }
            }
        }
        //设置罚款金额上下限，并赋值最小值
        var penalties = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'penalties'}).target;
        //2018-07-17
        var forfeitRange={};
        if(data.forfeitMin){
            forfeitRange.min =data.forfeitMin;
        }
        if(data.forfeitMax){
            forfeitRange.max=data.forfeitMax;
        }
        penalties.numberbox(forfeitRange);
        row.forfeitMin=data.forfeitMin;
        row.forfeitMax=data.forfeitMax;
        var penaltiesMin = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'penaltiesMin'}).target;
        penaltiesMin.numberbox('setValue', row.forfeitMin);
        penaltiesMin.numberbox('disable');
        var penaltiesMax = $('#dg').datagrid('getEditor', {  index : rowIndex,  field : 'penaltiesMax'}).target;
        penaltiesMax.numberbox('setValue', row.forfeitMax);
        penaltiesMax.numberbox('disable');
        /*if(row.penalties != null){
            penalties.numberbox('setValue', row.penalties);
        }else{
            penalties.numberbox('setValue', data.forfeitMin);
        }*/
    }
    /**
     * 责任方加载成功事件
     * */
    function dutyOnLoadSuccess(){
        var row = $('#dg').datagrid('getSelected');
        if(row.duty != 'undefined'){
            var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
            var thisTarget = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'duty'}).target;
            var val = thisTarget.combobox('getData');
            for (var i = 0; i < val.length; i++) {
                if (val[i].typeCode == row.duty) {
                    thisTarget.combobox('select', val[i].typeCode);
                }
            }
        }
    }

    /**
     *二级类型选中事件
     * */
    function secondeOnSelect(data){
        var row = $('#dg').datagrid('getSelected');
        row.secondeType=data.idStr;
        row.secondeTypeStr=data.idStr;
        row.secondeTypeName=data.name;
        var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
        var target = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'duty'}).target;
        target.combobox('clear'); //清除原来的数据
        var url = G_CTX_PATH+'/cs/CsWoDuty/getDuty.do?orderTypeId='+data.idStr;
        target.combobox('reload', url);//联动下拉列表重载--%>
    }
    /**
     *二级类型加载成功事件
     * */
    function secondeOnLoadSuccess(){
        var row = $('#dg').datagrid('getSelected');
        if(row.secondeTypeStr != 'undefined'){
            var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
            var thisTarget = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'secondeType'}).target;
            var val = thisTarget.combobox('getData');
            for (var i = 0; i < val.length; i++) {
                if (val[i].idStr == row.secondeTypeStr) {
                    thisTarget.combobox('select', val[i].idStr);
                }
            }
        }
    }
    /**
     *一级类型选中事件
     * */
    function firstOnSelect(data){

        var row = $('#dg').datagrid('getSelected');
        var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
        row.firstType=data.idStr;
        row.firstTypeStr=data.idStr;
        row.firstTypeName=data.name;
        var target = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'secondeType'}).target;
        target.combobox('clear'); //清除原来的数据
        var url = G_CTX_PATH+'/cs/CsWoDuty/datagrid_data1.do?kind='+woKind+'&parentId='+data.idStr;
        target.combobox('reload', url);//联动下拉列表重载

    }
    /**
     *一级类型加载成功事件
     * */
    function firstOnLoadSuccess(){
        var row = $('#dg').datagrid('getSelected');
        if(typeof row.firstTypeStr != 'undefined'){
            var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
            var thisTarget = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'first'}).target;
            var val = thisTarget.combobox('getData');
            for (var i = 0; i < val.length; i++) {
                if (val[i].idStr == row.firstTypeStr) {
                    thisTarget.combobox('select', val[i].idStr);
                }
            }
        }
    }
    /**
     *操作列
     * */
    function btnDetailed(value,row,index) {
        if (!index) return;
        var ret='<a href="javascript:void(0)" class="icon-line iconfont uce-delete"  onclick="removeit(\''+this+'\',\''+row.id+'\',\''+index+'\')">删除</a>';
        return ret;
    }

    /**
     *编辑完成校验
     * */
    var editIndex = undefined;
    function endEditing(){
        debugger;
        if (editIndex == undefined){return true}
        if ($('#dg').datagrid('validateRow', editIndex)){
            var sameDutyData = checkSameDutyData();
            if(sameDutyData){
                showInfoMsg('该定责数据重复，请审查');
                return false;
            }else{
                $('#dg').datagrid('endEdit', editIndex);
                var rowData = $('#dg').datagrid('getData').rows;
                var i = editIndex;
                //必填顶着信息不能为空校验 @author:Sunny by 2018/12/24
                if(uce.isNull(rowData[i].firstTypeStr)||uce.isNull(rowData[i].secondeTypeStr)||uce.isNull(rowData[i].duty)||uce.isNull(rowData[i].penalties)){
                    $('#dg').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
                    var formValidate = $('#dg').datagrid('validateRow', editIndex);
                    if(formValidate){
                        $('#dg').datagrid('endEdit', editIndex);
                    }else{
                        return false;
                    }
                } else {
                    if (rowData[i].typeName != '客户原因' || rowData[i].typeName != '总部') {
                        editIndex = undefined;
                        return true;
                    } else if (rowData[i].dutyName != '客服责任' && uce.isNull(rowData[i].dutyOrgCode)) {
                        $('#dg').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
                        var formValidate = $('#dg').datagrid('validateRow', editIndex);
                        if (formValidate) {
                            $('#dg').datagrid('endEdit', editIndex);
                        } else {
                            return false;
                        }
                    }
                }
                editIndex = undefined;
                return true;
            }
        } else {
            showInfoMsg('请完善当前行信息');
            return false;
        }
    }
    /**
     *双击行事件，启用编辑
     * */
    var shuangji = 0;
    var oldDuty = null;
    function onClickRow(index,row){
        editIndex = undefined;
        if(row.isFinal != 1){
            if (editIndex != index){
                if (endEditing()){
                    $('#dg').datagrid('selectRow', index)
                        .datagrid('beginEdit', index);
                    editIndex = index;
                    shuangji = 1;
                } else {
                    $('#dg').datagrid('selectRow', editIndex);
                }
                oldDuty = $('#dg').datagrid('getSelected').duty;
            }
        }else{
            showInfoMsg('该定责结果目前不可更改');
        }


    }
    /**
     *新增行事件
     * */
    function append(row,index){
        if(0 == $('#dg').datagrid('getRows').length){
            editIndex = undefined;
        }
        if (endEditing()){
            $('#dg').datagrid('appendRow',{});
            editIndex = $('#dg').datagrid('getRows').length-1;
            $('#dg').datagrid('refreshRow', editIndex);
            $('#dg').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
        }
    }
    /**
     *删除行事件
     * */
    function removeit(obj,id,index){
        if(typeof(index) != "undefined"){
            if(typeof(editIndex) != "undefined"){
                $('#dg').datagrid('endEdit', editIndex);
                $('#dg').datagrid('unselectRow',editIndex);
                editIndex = undefined;
            }
            //业务逻辑删除
            confirmMsg("您确认要删除该行定责信息吗?", function(){
                if(typeof(id) != "undefined"){
                    uceAjax(G_CTX_PATH+"/cs/CsWoDuty/batchDelete.do",{idStr:id},function (result) {
                        if(result.success) {
                            $('#dg').datagrid('cancelEdit', index).datagrid('deleteRow', index);
                            showInfoMsg("删除成功");
                            //刷新数据
                            var rows = $('#dg').datagrid("getRows");
                            $('#dg').datagrid("loadData", rows);
                        }
                    },"POST");
                }else{
                    $('#dg').datagrid('cancelEdit', index).datagrid('deleteRow', index);
                    showInfoMsg("删除成功");
                    //刷新数据
                    var rows = $('#dg').datagrid("getRows");
                    $('#dg').datagrid("loadData", rows);
                }
            });
        }else{
            var row = $('#dg').datagrid('getSelected');
            var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
            if(row != null){
                confirmMsg("您确认要删除该行定责信息吗?", function(){
                    if(typeof(row.id) != "undefined"){
                        uceAjax(G_CTX_PATH+"/cs/CsWoDuty/batchDelete.do",{idStr:row.id},function (result) {
                            if(result.success) {
                                $('#dg').datagrid('cancelEdit', rowIndex).datagrid('deleteRow', rowIndex);
                                /*showInfoMsg("删除成功", "", 2000);*/
                                showInfoMsg("删除成功");
                                //刷新数据
                                var rows = $('#dg').datagrid("getRows");
                                $('#dg').datagrid("loadData", rows);
                            }
                            rowIndex = undefined;
                        },"POST");

                    }else{
                        $('#dg').datagrid('cancelEdit', rowIndex).datagrid('deleteRow', rowIndex);
                        /*showInfoMsg("删除成功", "", 2000);*/
                        showInfoMsg("删除成功");
                        //刷新数据
                        var rows = $('#dg').datagrid("getRows");
                        $('#dg').datagrid("loadData", rows);
                        rowIndex = undefined;
                    }

                });

            }else{
                /*showTips("请选定一条数据再进行删除",'warning',1000);*/
                showInfoMsg("请选定一条数据再进行删除");
            }
        }
    }
    function accept(){
        if (endEditing()){
            $('#dg').datagrid('acceptChanges');
        }
    }
    function reject(){
        $('#dg').datagrid('rejectChanges');
        editIndex = undefined;
    }
    function getChanges(){
        var rows = $('#dg').datagrid('getChanges');
        alert(rows.length+' rows are changed!');
    }


    /**
     * 校验数据是否重复
     * 2018-07-04
     * **/
    function checkSameDutyData(){
        var sameDutyData = false;
        //获取表格所有的数据，进行比对，去重
        var rowData = $('#dg').datagrid('getData').rows;
        var row =rowData[editIndex];
        for(var i in rowData){
            if(i != editIndex && rowData[i].firstTypeStr == row.firstTypeStr && rowData[i].secondeTypeStr == row.secondeTypeStr && rowData[i].duty == row.duty && rowData[i].personLiableCode == row.personLiableCode
                &&rowData[i].dutyOrgCode == row.dutyOrgCode){
                sameDutyData = true;
                break;
            }
        }
        return sameDutyData;
    }

    /**
     * 2018-09-26
     *一级类型change事件
     * */
    function firstTypeChange(){
        var row = $('#dg').datagrid('getSelected');
        var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'secondeType'}).target.combobox('clear');
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'duty'}).target.combobox('clear');
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'dutyOrgC'}).target.combobox('clear');
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'personLiableC'}).target.combobox('clear');
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'penalties'}).target.numberbox('clear');
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'penalties'}).target.numberbox({min:"",max:""});
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'penaltiesMin'}).target.numberbox('clear');
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'penaltiesMax'}).target.numberbox('clear');

    }

    /**
     * 2018-09-26
     *二级类型change事件
     * */
    function secondeTypeChange(){
        var row = $('#dg').datagrid('getSelected');
        row.duty="";
        var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'duty'}).target.combobox('clear');
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'dutyOrgC'}).target.combobox('clear');
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'personLiableC'}).target.combobox('clear');
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'penalties'}).target.numberbox('clear');
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'penalties'}).target.numberbox({min:"",max:""});
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'penaltiesMin'}).target.numberbox('clear');
        $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'penaltiesMax'}).target.numberbox('clear');
    }

    /**
     *combox清空值
     */
    function comboboxClearValue(){
        var $node = $(this);
        var value = $node.combobox('getValue');
        var data = $node.combobox('getData');
        if(data.length == 0){
            $node.combobox('setValue','');
            $node.combobox('setText','');
            return false;
        }
        var isNull = true;
        $.each(data,function(index,node){
            if(value == node[$node.combobox('options').valueField]){
                isNull = false;
                return false;
            };
        });
        if(isNull){
            $node.combobox('setValue','');
            $node.combobox('setText','');
        }
    }

    /**@author Sunny by 20181103
     * 编辑会取不到当前编辑的行，这里手动选择
     */
    function selectRow(obj){
        var index = $(obj).parents("tr.datagrid-row").eq(0).attr("datagrid-row-index");
        $('#dg').datagrid('selectRow',index);
        console.log("手动选择第"+index+"行");
    }
</script>
<div id="tb" style="height:auto">
    <%--<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="append()">新增</a>--%>
</div>
<div class="table-edit" style="min-height:50px;width: 100%">
    <table id="dg" class="easyui-datagrid" style="width:100%;min-width:1000px;min-height:50px;"
           data-options="
                title:'<div>定责信息</div><a href=\'javascript:void(0)\' class=\'icon-line iconfont uce-add\' title=\'新增定责信息\' onclick=\'append()\'></a>',
				singleSelect: true,
				url: G_CTX_PATH+'/cs/CsWoDuty/getDutyByCode.do',
				method: 'get',
				queryParams: {workOrderKind: woKind, woCode: woCode},
				CanUserAddRows:'false',
				nowrap:false,
				onClickRow: function (rowIndex, rowData) {
                    $(this).datagrid('unselectRow', rowIndex);
                },
                onDblClickRow:onClickRow
			">
        <thead>
        <tr>
            <th data-options="field:'first',width:150,title:'一级类型',
                formatter:function(value,row){
                    return row.firstTypeName;
                },
                editor:{
                    type:'combobox',
                    options:{
                        valueField:'idStr',
                        textField:'name',
                        prompt: '---请选择---',
                        required:true,
                        method:'post',
                        url:G_CTX_PATH+'/cs/CsWoDuty/datagrid_data1.do',
                        multiple:false,
                        onBeforeLoad:function(param){
                            param.kind=woKind;
                        },
                        onLoadSuccess: function () { //数据加载完毕事件
                            firstOnLoadSuccess();
                        },
                        onSelect:function(data){
                            selectRow(this);
                            firstOnSelect(data);
                        },
                        onChange: function (newValue, oldValue) {
                            selectRow(this);
                            <%--firstTypeChange();--%>
                        },
                        onHidePanel: comboboxClearValue
                    }

                }"></th>
            <th data-options="field:'secondeType',width:170,title:'二级类型',
                formatter:function(value,row){
                    return row.secondeTypeName;
                },
                editor:{
                    type:'combobox',
                    options:{
                        valueField:'idStr',
                        textField:'name',
                        prompt: '---请选择---',
                        required:true,
                        method:'get',
                        onLoadSuccess: function () { //数据加载完毕事件
                           secondeOnLoadSuccess();
                        },
                        onSelect:function(data){
                            selectRow(this);
                            secondeOnSelect(data);
                        },
                        onChange: function (newValue, oldValue) {
                            selectRow(this);
                            <%--secondeTypeChange();--%>
                        },
                        onHidePanel: comboboxClearValue
                    }
                }"></th>
            <th data-options="field:'duty',width:150,title:'责任方',
                formatter:function(value,row){
                    return row.dutyName;
                },
                editor:{
                    type:'combobox',
                    options:{
                        valueField:'typeCode',
                        textField:'typeName',
                        prompt: '---请选择---',
                        required:true,
                        onLoadSuccess: function () { //数据加载完毕事件
                            dutyOnLoadSuccess();
                        },
                        onSelect:function(data){
                            selectRow(this);
                            dutyOnSelect(data);
                        },
                        onHidePanel: comboboxClearValue
                }
                }"></th>
            <th data-options="field:'dutyOrgC',width:120,editor:'textbox',title:'责任机构',
                formatter:function(value,row){
                    return row.dutyOrgName;
                },
                editor:{
                    type:'combobox',
                    options:{
                        url:G_CTX_PATH + '/cs/omg/org/findOrgCmsByOrgTypeAllStatusDB.do',
                        valueField:'baseOrgCode',
                        textField:'orgFullName',
                        required:true,
                        method:'get',
                        mode:'remote',
                        prompt: '---请选择---',
                        onBeforeLoad:function(param){
                            var row = $('#dg').datagrid('getSelected');
                            var duty = row.duty;
                            if(duty == 1){
                                param.orgTypeStr = '20,21';
                                param.defaultOrgType = '20';
                            }else{
                                param.orgTypeStr = '30';
                                param.defaultOrgType = '30';
                            }
                        },
                        onSelect:function(data){
                            selectRow(this);
                            dutyOrgCOnSelect(data);
                        },
                        onHidePanel: comboboxClearValue
                    }
                }"></th>
            <th data-options="field:'personLiableC',width:150,editor:'textbox',title:'责任人',
                        formatter:function(value,row){
							return row.personLiableName;
						},
						editor:{
							type:'combobox',
							options:{
							    width:100,
								valueField:'empCode',
								textField:'empName',
								prompt: '---请选择---',
								required:true,
								method:'get',
							    onLoadSuccess: function () { //数据加载完毕事件
                                    var row = $('#dg').datagrid('getSelected');
                                    if(row.secondeTypeStr != 'undefined'){
                                        var rowIndex = $('#dg').datagrid('getRowIndex',row);//获取行号
                                        var thisTarget = $('#dg').datagrid('getEditor', {'index':rowIndex,'field':'personLiableC'}).target;
                                        var val = thisTarget.combobox('getData');
                                        for (var i = 0; i < val.length; i++) {
                                            if (val[i].empCode == row.personLiableCode) {
                                                thisTarget.combobox('select', val[i].empCode);
                                            }
                                        }
                                    }
                                },
								onSelect:function(data){
								   selectRow(this);
								   personLiableCOnSelect(data);
						        },
								onHidePanel: comboboxClearValue
							}
						}"></th>
            <th data-options="field:'penalties',width:100,title:'罚款金额(元)',editor:{type:'numberbox',options:{required:true,precision:2,
                onChange:function(newValue,oldValue){
                    selectRow(this);
                    var row = $('#dg').datagrid('getSelected');
                    row.penalties = newValue;
                }
            }}"></th>
            <th data-options="field:'penaltiesMin',width:100,title:'罚款金额下限(元)',editor:{type:'numberbox',options:{precision:2}}"></th>
            <th data-options="field:'penaltiesMax',width:100,title:'罚款金额上限(元)',editor:{type:'numberbox',options:{precision:2}}"></th>
            <th data-options="field:'deal',width:60,align:'center',title:'操作',formatter:btnDetailed"></th>
        </tr>
        </thead>
    </table>

</div>



